// https://evp.51job.com/51job/api/1.0/index.php/msd/index/upload?token=x

import request from '../api';
import qs from 'qs';

export const getList = async (token) => {
  return await request.request({
    url: `/listschool?token=${token}`,
    method: 'GET',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
};

export const update = async (token, detail) => {
  const {id} = detail;
  // console.log(detail);
  return await request.request({
    url: `/saveschool?token=${token}&id=${id}`,
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: qs.stringify({
      name: detail.name,
      city: detail.city,
      logo: detail.logo
    })
  });
};

export const add = async (token, detail) => {
  return await request.request({
    url: `/addschool?token=${token}`,
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: qs.stringify({
      name: detail.name,
      city: detail.city,
      logo: detail.logo
    })
  });
};

export const del = async (token, id) => {
  return await request.request({
    url: `/delschool?token=${token}&id=${id}`,
    method: 'GET',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
};